package com.alstudio.view.progressDialog;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.widget.TextView;

import com.alstudio.R;

public class ALProgressDialog extends Dialog {

	private Context context = null;
	private static ALProgressDialog customProgressDialog = null;

	public ALProgressDialog(Context context) {
		super(context);
		this.context = context;
	}

	public ALProgressDialog(Context context, int theme) {
		super(context, theme);
	}

	public static ALProgressDialog createDialog(Context context) {
		customProgressDialog = new ALProgressDialog(context,R.style.CustomProgressDialog);
		customProgressDialog.setContentView(R.layout.base_waiting_progress_toast);
		customProgressDialog.getWindow().getAttributes().gravity = Gravity.CENTER;

		return customProgressDialog;
	}

//	public void onWindowFocusChanged(boolean hasFocus) {
//
//		if (customProgressDialog == null) {
//			return;
//		}
//
//		ImageView imageView = (ImageView) customProgressDialog
//				.findViewById(R.id.loadingImageView);
//		AnimationDrawable animationDrawable = (AnimationDrawable) imageView
//				.getBackground();
//		animationDrawable.start();
//	}

	/**
	 * 
	 * [Summary] setTitile 标题
	 * 
	 * @param strTitle
	 * @return
	 * 
	 */
	public ALProgressDialog setTitile(String strTitle) {
		return customProgressDialog;
	}

	/**
	 * 
	 * [Summary] setMessage 提示内容
	 * 
	 * @param strMessage
	 * @return
	 * 
	 */
	public ALProgressDialog setMessage(String strMessage) {
		TextView tvMsg = (TextView) customProgressDialog
				.findViewById(R.id.textView1);

		if (tvMsg != null) {
			tvMsg.setText(strMessage);
		}

		return customProgressDialog;
	}
}
